package com.bstek.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Title: SwaggerConfig
 * @Package: com.bstek.config
 * @Description:
 * @Author: zxq
 * @Date: 2024/1/4 - 16:35
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {
    @Bean
    public Docket api(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(getApiInfo())
                .groupName("模块1")
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bstek.sample"))
                .paths(PathSelectors.any())
                .build();
    }
    @Bean
    public Docket docketUser(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(getApiInfo())
                .groupName("实体类模块")
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bstek.sample.domain"))
                .paths(PathSelectors.any())
                .build();
    }

    public ApiInfo getApiInfo(){
        ApiInfo build = new ApiInfoBuilder()
                .title("API Documentation By Swagger3!接口文档")
                .description("swagger3")
                .contact(new Contact("Arthur", "http://lcoalhost", "my@163.com"))
                .version("1.0")
                .license("Apache 2.0")
                .licenseUrl("https://www.apache.org/licenses/LICENSE-2.0")
                .build();
        return build;
    }
 
}
